package org.jxc.service; 


import org.hibernate.SessionFactory;
import org.jxc.dao.BackPurchaseDAO;
import org.jxc.domain.BackPurchase;
import org.springframework.beans.factory.annotation.Autowired;
import org.team4.dao.DAOFactory;
import org.team4.exception.CRUDException;
import org.team4.service.IService;
import org.team4.vo.Page;

public class BackPurchaseService implements IService {

	private BackPurchaseDAO backPurchaseDAO ;
	
	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		backPurchaseDAO = (BackPurchaseDAO) DAOFactory.getDAO(sessionFactory, BackPurchaseDAO.class);
	}

	public Page<BackPurchase> listPagination(Page<BackPurchase> page) throws CRUDException {
		return backPurchaseDAO.pagination(page, "from BackPurchase where deleteFlag = '0'", null);
	}

	public void save(BackPurchase object) throws CRUDException {
		backPurchaseDAO.save(object);
	}

	public void delete(String id) throws CRUDException {
		BackPurchase temp = backPurchaseDAO.get(id);
		temp.setDeleteFlag("1");
		backPurchaseDAO.update(temp);
	}

	public BackPurchase findById(String id) throws CRUDException {
		return backPurchaseDAO.get(id);
	}

	public void update(BackPurchase object) throws CRUDException {
		backPurchaseDAO.update(object);
	}

}
